home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SplashWindow.cp
-
- Contains: a simple splash screen window
-
- Written by: Dave Falkenburg
-
- Copyright: Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/19/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
- 11/16/94 DRF Add (StringPtr) cast to make PPCC happier.
- 11/12/94 DRF Use NewColorOrBlackAndWhiteWindow.
- 11/8/94 DRF Deal with a missing splash picture.
- 9/27/94 DRF AppLib.h is now Sprocket.h
- 9/9/94 DRF Reordered headers and removed redundant #includes.
-
-
- */
-
- #include "Sprocket.h"
- #include "SplashWindow.h"
-
- #include <ToolUtils.h>
- #include <Resources.h>
-
-
- TSplashWindow::TSplashWindow()
- {
- this->CreateWindow(kNormalWindow);
- }
-
-
- TSplashWindow::~TSplashWindow()
- {
- if (fSplashPicture)
- DisposeHandle((Handle) fSplashPicture);
-
- this->Close();
- }
-
-
- WindowPtr
- TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
- {
- GrafPtr oldPort;
- Rect splashPictRect,windowRect;
- WindowPtr splashWindow;
-
- GetPort(&oldPort);
-
- fSplashPicture = GetPicture(kSplashPictureID);
-
- if (fSplashPicture)
- {
- MoveHHi((Handle) fSplashPicture); // get it out of the way
- splashPictRect = (**fSplashPicture).picFrame;
- }
- else
- SetRect(&splashPictRect,0,0,0,0);
-
- // normalize the rectangle
- OffsetRect(&splashPictRect,-splashPictRect.left,-splashPictRect.top);
-
- // center it on the main screen
- windowRect = splashPictRect;
- OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
-
- splashWindow = NewColorOrBlackAndWhiteWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
-
- if (fSplashPicture)
- {
- DetachResource((Handle) fSplashPicture); // need to do so we don’t botch the resource map after closing
- SetWindowPic(splashWindow,fSplashPicture); // in case an Alert comes up
- }
-
- ShowWindow(splashWindow);
- SetPort(splashWindow);
- BeginUpdate(splashWindow); // avoid a flashing update event later
- if (fSplashPicture)
- DrawPicture(fSplashPicture,&splashPictRect);
- EndUpdate(splashWindow); // avoid a flashing update event later
-
- SetPort(oldPort);
- return splashWindow;
- }
-